package club.xinghe.servlet.teacher;

import club.xinghe.biz.TeacherBiz;
import club.xinghe.entity.Class;
import club.xinghe.entity.Score;
import club.xinghe.util.JsonServlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/teacher/ScoreAnalysisServlet")
public class ScoreAnalysisServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int cId= Integer.parseInt(request.getParameter("cId"));
        int eId= Integer.parseInt(request.getParameter("eId"));
        int zId= Integer.parseInt(request.getParameter("zId"));
        int gid= Integer.parseInt(request.getParameter("gid"));

        TeacherBiz teacherBiz=new TeacherBiz();
        List<Score> scoreList=teacherBiz.getAllScoreByClass(gid,zId,eId,cId);
        System.out.println(scoreList.size());
        if(scoreList.size()>0){
            JsonServlet.getJson(request,response,scoreList);
        }
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req,resp);
    }
}
